<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: abcc
  Date: 2019/10/4
  Time: 13:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <!-- 引入bootstrap框架的样式文件 -->
    <link rel="stylesheet" href="${path}/plugins/bootstrap/css/bootstrap.min.css" type="text/css">
    <link rel="stylesheet" href="${path}/css/person/safety/safety.css">

    <link rel="stylesheet" href="${path}/css/person/safety/jquery.steps.css">
    <style>
        .wizard-big.wizard > .content {
            min-height: 400px;
        }
    </style>
</head>

<body>
<!--导航-->
<%@include file="../sharedper/nav.jsp"%>

    <!-- 主体部分 -->
    <div class="container" style="width: 1015px;margin-top: 50px">
        <div class="col-sm-12" style="background: white;">
            <div class="zt">
                <p class="info" id="safety1">修改密码</p>
                <p id="safety2">绑定邮箱</p>
                <p id="safety4">绑定手机</p>
                <p id="safety3">实名认证</p>
            </div>

            <div id="block2" style="display: none">
                <div class="ibox">
                    <div class="ibox-content">
                        <p>
                            &nbsp;
                        </p>
                        <form id="form" action="${path}/add/email" class="wizard-big" method="post" onsubmit="isHave()">
                            <h1>确认账户信息</h1>
                            <fieldset>
                                <h2>账户信息</h2>
                                <div class="row">
                                    <div class="col-sm-8">
                                        <div class="form-group">
                                            <label>账号 *</label>
                                            <input name="userId" type="text"
                                                   class="form-control required" value="${sessionScope.user.userId}" readonly="readonly">
                                        </div>
                                        <div class="form-group">
                                            <label>密码 *</label>
                                            <input id="epassword" name="userPassword" type="password"
                                                   class="form-control required remote">
                                            <%--onblur="isRight(${sessionScope.user.userId},this)--%>
                                        </div>
                                        <div class="form-group">
                                            <label>确认密码 *</label>
                                            <input id="econfirm"  name="confirm" type="password"
                                                   class="form-control required">
                                        </div>
                                    </div>
                                    <div class="col-sm-4">
                                        <div class="text-center">
                                            <div style="margin-top: 20px">
                                                <i class="fa fa-sign-in"
                                                   style="font-size: 180px;color: #e5e5e5 "></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </fieldset>

                        <c:if test="${sessionScope.info.uEmail == null}">
                            <h1>绑定邮箱</h1>
                            <fieldset>
                                <!-- <div class="text-center" style="margin-top: 120px"> -->
                                <h2>邮箱绑定</h2>
                                <div class="row">
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label>Email *</label>
                                            <input id="email" name="uEmail" type="text"
                                                   class="form-control required email">
                                            <input type="hidden" name="id" value="${sessionScope.user.id}">
                                        </div>
                                    </div>
                                </div>
                            </fieldset>
                        </c:if>

                        <c:if test="${sessionScope.info.uEmail != null}">
                            <h1>解绑邮箱</h1>
                            <fieldset>
                                <!-- <div class="text-center" style="margin-top: 120px"> -->
                                <h2>邮箱解绑</h2>
                                <div class="row">
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label>Email *</label>
                                            <input id="emails" name="uEmail" type="text"
                                                   class="form-control required email" value="${fn:replace(sessionScope.info.uEmail,fn:substring(sessionScope.info.uEmail,5,-1),"********")}" readonly="readonly">
                                            <input type="hidden" name="id" value="${sessionScope.user.id}">
                                            <input type="hidden" id="reEmail02" value="${sessionScope.info.uEmail}">
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <button type="button" class="btn btn-warning" style="margin-top: 27px;margin-left: -17px;" data-toggle="modal" data-target="#myModal">解除绑定</button>
                                        <%--模态框--%>
                                        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                            <div class="modal-dialog">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                                            &times;
                                                        </button>
                                                        <h4 class="modal-title" id="myModalLabel">
                                                            请补全邮箱
                                                        </h4>
                                                    </div>
                                                    <div class="modal-body">
                                                        <input type="text" class="form-control" id="reEmail01" placeholder="请输入邮箱的全地址">
                                                    </div>
                                                    <div class="modal-footer">
                                                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                                                        </button>
                                                        <button type="button" class="btn btn-primary" onclick="removeEmail()">
                                                            提交更改
                                                        </button>
                                                    </div>
                                                </div><!-- /.modal-content -->
                                            </div><!-- /.modal -->
                                        </div>
                                        <%--模态结束--%>
                                    </div>
                                </div>
                            </fieldset>
                        </c:if>
                            <h1>完成</h1>
                            <fieldset>
                                <h4>最后一步啦,点击完成,操作成功</h4>
                                <!-- <input id="acceptTerms" name="acceptTerms" type="checkbox" class="required"> -->
                                <label for="acceptTerms"></label>
                            </fieldset>
                        </form>
                    </div>
                </div>
            </div>

        <%--修改密码!!!!!!!!!!--%>
            <div id="block1">
                <div class="ibox">
                    <div class="ibox-content">
                        <p>
                            &nbsp;
                        </p>
                        <form id="form1" action="${path}/edit/pass" class="wizard-big" method="post" onsubmit="isHave()">
                            <h1>修改密码</h1>
                            <fieldset>
                                <h2>账户信息</h2>
                                <div class="row">
                                    <div class="col-sm-8">
                                        <div class="form-group">
                                            <label>账号 *</label>
                                            <input name="userId" type="text"
                                                   class="form-control required" value="${sessionScope.user.userId}" readonly="readonly">
                                        </div>

                                        <div class="form-group">
                                            <label>原密码 *</label>
                                            <input id="oldpass" type="password" name="oldpass"
                                                   class="form-control required remote">
                                        </div>

                                        <div class="form-group">
                                            <label>密码 *</label>
                                            <input id="gpassword" name="userPassword" type="password"
                                                   class="form-control required">
                                        </div>
                                        <div class="form-group">
                                            <label>确认密码 *</label>
                                            <input id="confirm"  name="confirm" type="password"
                                                   class="form-control required">
                                        </div>
                                    </div>
                                    <div class="col-sm-4">
                                        <div class="text-center">
                                            <div style="margin-top: 20px">
                                                <i class="fa fa-sign-in"
                                                   style="font-size: 180px;color: #e5e5e5 "></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </fieldset>

                        </form>
                    </div>
                </div>
            </div>


            <!-- 实名认证 -->
            <div id="block3" style="display: none">
                <div class="ibox">
                    <div class="ibox-content">
                        <p>
                            &nbsp;
                        </p>

                        <form id="form3" action="${path}/add/position" class="wizard-big" method="post" onsubmit="isHave()">
                            <h1>验证账户信息</h1>
                            <fieldset>
                                <h2>账户信息</h2>
                                <div class="row">
                                    <div class="col-sm-8">
                                        <div class="form-group">
                                            <label>账号 *</label>
                                            <input name="userId" type="text"
                                                   class="form-control required" value="${sessionScope.user.userId}" readonly="readonly">
                                            <input type="hidden" name="id" value="${sessionScope.user.id}">
                                        </div>
                                        <div class="form-group">
                                            <label>密码 *</label>
                                            <input id="spassword" name="userPassword" type="password"
                                                   class="form-control required remote">
                                        </div>
                                        <div class="form-group">
                                            <label>确认密码 *</label>
                                            <input id="sconfirm" name="confirm" type="password"
                                                   class="form-control required">
                                        </div>
                                    </div>
                                    <div class="col-sm-4">
                                        <div class="text-center">
                                            <div style="margin-top: 20px">
                                                <i class="fa fa-sign-in"
                                                   style="font-size: 180px;color: #e5e5e5 "></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </fieldset>
                            <%--绑定身份证--%>
                        <c:if test="${sessionScope.user.numder == null}">
                            <h1>实名认证</h1>
                            <fieldset>
                                <h2>个人信息</h2>
                                <div class="row">
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label>姓名 *</label>
                                            <input id="name" name="name" type="text" class="form-control required">
                                        </div>
                                    </div>
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <!-- !!!验证问题  实名认证 -->
                                            <label>身份证号 *</label>
                                            <input id="card" name="numder" type="text"
                                                   class="form-control required">
                                        </div>
                                        <%--<div class="form-group">--%>
                                            <%--<label>地址 *</label>--%>
                                            <%--<input id="address" name="address" type="text" class="form-control">--%>
                                        <%--</div>--%>
                                    </div>
                                </div>
                            </fieldset>
                        </c:if>

                            <%--解除身份证绑定--%>
                        <c:if test="${sessionScope.user.numder != null}">
                            <h1>实名认证</h1>
                            <fieldset>
                                <h2>个人信息</h2>
                                <div class="row">
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label>姓名 *</label>
                                            <input id="names" name="name" type="text" class="form-control required" value="${sessionScope.user.name}" readonly="readonly">
                                        </div>
                                    </div>
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <!-- !!!验证问题 -->
                                            <label>身份证号 *</label>
                                            <input type="hidden" id="reNumder01" value="${sessionScope.user.numder}">
                                            <input id="cards" name="numder" type="text"
                                                   class="form-control required" value="${fn:replace(sessionScope.user.numder,fn:substring(sessionScope.user.numder,5,-1),"********")}" readonly="readonly">
                                        </div>

                                    </div>
                                    <button type="button" class="btn btn-warning" style="margin-left: 783px;" data-toggle="modal" data-target="#myModals">解除绑定</button>
                                        <%--模态框--%>
                                    <div class="modal fade" id="myModals" tabindex="-1" role="dialog" aria-labelledby="myModalLabels" aria-hidden="true">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                                        &times;
                                                    </button>
                                                    <h4 class="modal-title" id="myModalLabels">
                                                        请补全你的身份证号
                                                    </h4>
                                                </div>
                                                <div class="modal-body">
                                                    <input type="text" class="form-control" id="reNumder02" placeholder="请补全你的身份证号">
                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                                                    </button>
                                                    <button type="button" class="btn btn-primary" onclick="removeNumder()">
                                                        提交更改
                                                    </button>
                                                </div>
                                            </div><!-- /.modal-content -->
                                        </div><!-- /.modal -->
                                    </div>
                                        <%--模态结束--%>
                                </div>
                            </fieldset>
                        </c:if>


                            <h1>完成</h1>
                            <fieldset>
                                <h2>条款</h2>
                                <input id="acceptTerms" name="acceptTerms" type="checkbox" class="required">
                                <label for="acceptTerms">我同意注册条款</label><br>
                                <h3>恭喜您,完成实名认证</h3>
                            </fieldset>
                        </form>
                    </div>
                </div>
            </div>



            <%--绑定手机!!!!!!!!!!--%>
            <div id="block4" style="display: none">
                <div class="ibox">
                    <div class="ibox-content">
                        <p>
                            &nbsp;
                        </p>
                        <form id="form4" action="${path}/add/phone" class="wizard-big" method="post" onsubmit="isHave()">
                            <h1>确认账户信息</h1>
                            <fieldset>
                                <h2>验证账户信息</h2>
                                <div class="row">
                                    <div class="col-sm-8">
                                        <div class="form-group">
                                            <label>账号 *</label>
                                            <input name="userId" type="text"
                                                   class="form-control required" value="${sessionScope.user.userId}" readonly="readonly">
                                            <input type="hidden" name="id" value="${sessionScope.user.id}">
                                        </div>
                                        <div class="form-group">
                                            <label>密码 *</label>
                                            <%--<span id="message"></span>--%>
                                            <input id="ppassword" name="userPassword" type="password"
                                                   class="form-control required remote">
                                        </div>
                                        <div class="form-group">
                                            <label>确认密码 *</label>
                                            <input id="pconfirm" name="confirm" type="password"
                                                   class="form-control required">
                                        </div>
                                    </div>
                                    <div class="col-sm-4">
                                        <div class="text-center">
                                            <div style="margin-top: 20px">
                                                <i class="fa fa-sign-in"
                                                   style="font-size: 180px;color: #e5e5e5 "></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </fieldset>
                        <c:if test="${sessionScope.info.uPhone != null}">
                            <h1>解绑手机</h1>
                            <fieldset>
                                <h2>解绑手机号</h2>
                                <div class="row">
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label>电话号码 *</label>
                                            <input id="Jphone" name="JPhone" type="text" class="form-control required" value="${sessionScope.info.uPhone}" readonly="readonly">
                                            <input name="uPhone" type="hidden">
                                        </div>
                                    </div>

                                    <div class="col-sm-4">
                                        <div class="form-group">
                                            <label>验证码 *</label>
                                            <input name="validations" type="text" id="yzm" class="form-control required">
                                            <span id="error01" data-placement="top" title="请稍后再试" style="margin-left: 170px;color: #999999;cursor: pointer;">收不到验证码?</span>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <button type="button" class="btn btn-warning" style="margin-top: 27px;margin-left: -17px;" id="JsendCode" onclick="rePhones()">发送验证码</button>
                                    </div>
                                </div>
                            </fieldset>
                        </c:if>
                        <c:if test="${sessionScope.info.uPhone == null}">
                            <h1>绑定手机</h1>
                            <fieldset>
                                <h2>绑定手机号</h2>
                                <div class="row">
                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label>电话号码 *</label>
                                            <input id="phone" name="uPhone" type="text" class="form-control required">
                                        </div>
                                    </div>
                                    <div class="col-sm-4">
                                        <div class="form-group">
                                            <label>验证码 *</label>
                                            <input name="validations" type="text" id="yzm" class="form-control required">
                                            <span id="error02" data-toggle="tooltip" data-placement="top" title="请稍后再试" style="margin-left: 170px;color: #999999;cursor: pointer;">收不到验证码?</span>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <button type="button" class="btn btn-warning" style="margin-top: 27px;margin-left: -17px;" id="sendCode" onclick="addPhones()">发送验证码</button>
                                    </div>
                                </div>
                            </fieldset>
                        </c:if>
                        <h1>完成</h1>
                        <fieldset>
                            <h2>操作成功</h2>
                            <!-- <input id="acceptTerms" name="acceptTerms" type="checkbox" class="required"> -->
                            <label for="acceptTerms"></label>
                        </fieldset>


                        </form>
                    </div>
                </div>
            </div>


        </div>
    </div>

    <script src="${path}/plugins/jquery/jquery.min.js"></script>
    <script src="${path}/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="${path}/js/person/safety/jquery.steps.min.js"></script>
    <script src="${path}/js/person/safety/jquery.validate.min.js"></script>
    <script src="${path}/js/person/safety/messages_zh.min.js"></script>

    <script>
        //传过来正确的email
        function removeEmail() {
            //利用id获取值
            var re = $("#reEmail01").val();
            //alert(re);
            var email = $("#reEmail02").val();
            //alert(email);
            console.log("123456");
            if(re==email){
                $.post("${path}/del/email/"+${sessionScope.user.id},{id:${sessionScope.user.id}},function (data) {
                    if(data==true){
                        alert("解绑成功!");
                        window.location='${path}/info/agent';
                    }
                });
            }else{
                alert("邮箱地址输入有误,绑定失败!")
            }
        }

        function removeNumder() {
            //利用id获取值(re是获取我要移除的值)
            var re = $("#reNumder01").val();
            // alert(re);
            //正确值
            var numder = $("#reNumder02").val();
            // alert(numder);
            console.log("123456");
            if(re==numder){
                //利用账号实现
                $.post("${path}/del/numder/"+${sessionScope.user.userId},{id:${sessionScope.user.userId}},function (data) {
                    if(data==true){
                        alert("解绑成功!");
                        window.location='${path}/info/agent';
                    }
                });
            }else{
                alert("身份证号地址输入有误,解绑失败,请重新输入")
            }
        }

        // 手机号码验证
        jQuery.validator.addMethod("isMobile", function(value, element) {
            var length = value.length;
            var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
            return this.optional(element) || (length == 11 && mobile.test(value));
        }, "请正确填写您的手机号码");

        //密码验证
        jQuery.validator.addMethod("isPassword", function(value, element) {
            var reg =  /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{6,20}$/;
            return reg.test(value);
        }, "密码中必须包含含数字、字母、特殊符号");

        function rePhones() {
            // $("#JsendCode").click(function () {
                console.log("ffffff");
                $.post("${path}/user/getcode",
                    {
                        phoneNumber:document.getElementById("Jphone").value
                    },
                    function (data) {
                        alert(data);
                        console.log(data);
                        if(data=="已获取手机号并发送"){
                            document.getElementById("JsendCode").innerText="已发送";
                        }
                        if(data=="发送失败"){
                            document.getElementById("JsendCode").innerText="发送失败";
                        }
                    }
                )
            // });
        }

       function addPhones() {
            console.log("ffffffadd");
            $.post("${path}/user/getcode",
                {
                    phoneNumber:document.getElementById("phone").value
                },
                function (data) {
                    alert(data);
                    console.log(data);
                    if(data=="已获取手机号并发送"){
                        document.getElementById("sendCode").innerText="已发送";
                    }
                    if(data=="发送失败"){
                        document.getElementById("sendCode").innerText="发送失败";
                    }
                }
            )
       }
        // });
        <%--function sendCode() {--%>
            <%--$.post("${path}/user/getcode",--%>
                <%--{--%>
                    <%--phoneNumber:document.getElementById("regphone").value--%>
                <%--},--%>
                <%--function (data) {--%>
                    <%--if(data=="已获取手机号并发送"){--%>
                        <%--document.getElementById("getCode").innerText="已发送";--%>
                    <%--}--%>
                    <%--if(data=="发送失败"){--%>
                        <%--document.getElementById("getCode").innerText="发送失败";--%>
                    <%--}--%>
                <%--}--%>
        <%--}--%>

        //实名认证(是否有重复)
        jQuery.validator.addMethod("cardExist", function(value, element) {
            return this.optional(element) || cardExist(value);
        }, "该证件已经绑定到其他用户,请重新输入");

        $(document).ready(function(){
            $("#error02").tooltip();
            $("#error01").tooltip();
        });
        $.validator.addMethod("isIdCardNo", function(value, element) {
            return this.optional(element) || isIdCardNo(value);
        }, "请正确输入您的身份证号码");

        function cardExist(num) {
            var s = false;
            $.ajax({
                async:false,
                type:"get",
                url:"${path}/info/isCard/"+num,
                dataType:"text",
                success:function (data) {
                    if(data=="true") {
                        // alert(s);
                        s = true;
                        return;
                    }
                    else {
                        s = false;
                        return;
                    }
                }
            });
            console.log(s);
            return s;
        }
        // --身份证号码验证-支持新的带x身份证
        function isIdCardNo(num) {
            var factorArr = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4,
                2, 1);
            var error;
            var varArray = new Array();
            var intValue;
            var lngProduct = 0;
            var intCheckDigit;
            var intStrLen = num.length;
            var idNumber = num;
            // initialize
            if ((intStrLen != 15) && (intStrLen != 18)) {
                // error = "输入身份证号码长度不对！";
                // alert(error);
                // frmAddUser.txtIDCard.focus();
                return false;
            }
            // check and set value
            for (i = 0; i < intStrLen; i++) {
                varArray[i] = idNumber.charAt(i);
                if ((varArray[i] < '0' || varArray[i] > '9') && (i != 17)) {
                    // error = "错误的身份证号码！.";
                    // alert(error);
                    // frmAddUser.txtIDCard.focus();
                    return false;
                } else if (i < 17) {
                    varArray[i] = varArray[i] * factorArr[i];
                }
            }
            if (intStrLen == 18) {
                // check date
                var date8 = idNumber.substring(6, 14);
                if (isDate8(date8) == false) {
                    // error = "身份证中日期信息不正确！.";
                    // alert(error);
                    return false;
                }
                // calculate the sum of the products
                for (i = 0; i < 17; i++) {
                    lngProduct = lngProduct + varArray[i];
                }
                // calculate the check digit
                intCheckDigit = 12 - lngProduct % 11;
                switch (intCheckDigit) {
                    case 10:
                        intCheckDigit = 'X';
                        break;
                    case 11:
                        intCheckDigit = 0;
                        break;
                    case 12:
                        intCheckDigit = 1;
                        break;
                }
                // check last digit
                if (varArray[17].toUpperCase() != intCheckDigit) {
                    // error = "身份证效验位错误!...正确为： " + intCheckDigit + ".";
                    // alert(error);
                    return false;
                }
            }
            else { // length is 15
                // check date
                var date6 = idNumber.substring(6, 12);
                if (isDate6(date6) == false) {
                    // alert("身份证日期信息有误！.");
                    return false;
                }
            }
            // alert ("Correct.");
            return true;
        }
        function isDate6(sDate) {
            if (!/^[0-9]{6}$/.test(sDate)) {
                return false;
            }
            var year, month, day;
            year = sDate.substring(0, 4);
            month = sDate.substring(4, 6);
            if (year < 1700 || year > 2500)
                return false
            if (month < 1 || month > 12)
                return false
            return true
        }
        function isDate8(sDate) {
            if (!/^[0-9]{8}$/.test(sDate)) {
                return false;
            }
            var year, month, day;
            year = sDate.substring(0, 4);
            month = sDate.substring(4, 6);
            day = sDate.substring(6, 8);
            var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
            if (year < 1700 || year > 2500)
                return false
            if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
                iaMonthDays[1] = 29;
            if (month < 1 || month > 12)
                return false
            if (day < 1 || day > iaMonthDays[month - 1])
                return false
            return true
        }



        $(document).ready(function () {
            $("#wizard").steps();
            // 模块2  邮箱
            $("#form").steps({
                bodyTag: "fieldset",
                onStepChanging: function (event, currentIndex, newIndex) {
                    // Always allow going backward even if the current step contains invalid fields!
                    if (currentIndex > newIndex) {
                        return true;
                    }

                    // Forbid suppressing "Warning" step if the user is to young
                    if (newIndex === 3 && Number($("#age").val()) < 18) {
                        return false;
                    }

                    var form = $(this);

                    // Clean up if user went backward before
                    if (currentIndex < newIndex) {
                        // To remove error styles
                        $(".body:eq(" + newIndex + ") label.error", form).remove();
                        $(".body:eq(" + newIndex + ") .error", form).removeClass("error");
                    }

                    // Disable validation on fields that are disabled or hidden.
                    form.validate().settings.ignore = ":disabled,:hidden";

                    // Start validation; Prevent going forward if false
                    return form.valid();
                },
                onStepChanged: function (event, currentIndex, priorIndex) {
                    // Suppress (skip) "Warning" step if the user is old enough.
                    if (currentIndex === 2 && Number($("#age").val()) >= 18) {
                        $(this).steps("next");
                    }

                    // Suppress (skip) "Warning" step if the user is old enough and wants to the previous step.
                    if (currentIndex === 2 && priorIndex === 3) {
                        $(this).steps("previous");
                    }
                },
                onFinishing: function (event, currentIndex) {
                    var form = $(this);

                    // Disable validation on fields that are disabled.
                    // At this point it's recommended to do an overall check (mean ignoring only disabled fields)
                    form.validate().settings.ignore = ":disabled";

                    // Start validation; Prevent form submission if false
                    return form.valid();
                },
                onFinished: function (event, currentIndex) {
                    var form = $(this);

                    // Submit form input
                    form.submit();
                }
            }).validate({
                errorPlacement: function (error, element) {
                    element.before(error);
                },
                rules: {
                    confirm: {
                        equalTo: "#epassword"
                    },
                    userPassword:{
                        remote: {
                            type: "get",
                            url: "${path}/info/detection",// {userId:userId,userPassword:pass},
                            data: {
                                userId:${sessionScope.user.userId},
                                userPassword: function() {
                                    return $("#epassword").val();
                                }
                            },
                            dataType: "html",
                            dataFilter: function(data, type) {
                                if (data == "true")
                                    return true;
                                else
                                    return false;
                            }
                        }
                    },
                    uEmail:{
                        remote:{
                            type:"get",
                            url:"${path}/info/isEmail",
                            data:{
                                uEmail:function () {
                                    return $("#email").val();
                                }
                            },
                            dataType: "html",
                            dataFilter: function(data, type) {
                                if (data == "true")
                                    return true;
                                else
                                    return false;
                            }
                        }
                    }
                },
                messages:{
                    userPassword:{
                        remote:"密码不正确!请重新输入."
                    },
                    uEmail:{
                        remote:"该邮箱已绑定到其他用户,请重新输入"
                    }
                }

            });

            //修改密码的
            // 模块一
            $("#form1").steps({
                bodyTag: "fieldset",
                onStepChanging: function (event, currentIndex, newIndex) {
                    if (currentIndex > newIndex) {
                        return true;
                    }
                    if (newIndex === 3 && Number($("#age").val()) < 18) {
                        return false;
                    }

                    var form = $(this);

                    if (currentIndex < newIndex) {

                        $(".body:eq(" + newIndex + ") label.error", form).remove();
                        $(".body:eq(" + newIndex + ") .error", form).removeClass("error");
                    }


                    form.validate().settings.ignore = ":disabled,:hidden";


                    return form.valid();
                },
                onStepChanged: function (event, currentIndex, priorIndex) {

                    if (currentIndex === 2 && Number($("#age").val()) >= 18) {
                        $(this).steps("next");
                    }


                    if (currentIndex === 2 && priorIndex === 3) {
                        $(this).steps("previous");
                    }
                },
                onFinishing: function (event, currentIndex) {
                    var form = $(this);

                    form.validate().settings.ignore = ":disabled";

                    return form.valid();
                },
                onFinished: function (event, currentIndex) {
                    var form = $(this);

                    form.submit();
                }
            }).validate({
                errorPlacement: function (error, element) {
                    element.before(error);
                },
                rules: {
                    confirm: {
                        equalTo: "#gpassword"
                    },
                    oldpass:{
                        remote: {
                            type: "get",
                            url: "${path}/info/detection",// {userId:userId,userPassword:pass},
                            data: {
                                userId:${sessionScope.user.userId},
                                userPassword: function() {
                                    return $("#oldpass").val();
                                }
                            },
                            dataType: "html",
                            dataFilter: function(data, type) {
                                if (data == "true")
                                    return true;
                                else
                                    return false;
                            }
                        }
                    },
                    userPassword:{
                        minlength: 6,
                        maxlength: 20,
                        isPassword:true
                    }
                },
                messages:{
                    oldpass:{
                        remote:"密码不正确!请重新输入."
                    }
                }
            });


            //模块三   实名
            $("#form3").steps({
                bodyTag: "fieldset",
                onStepChanging: function (event, currentIndex, newIndex) {
                    if (currentIndex > newIndex) {
                        return true;
                    }
                    if (newIndex === 3 && Number($("#age").val()) < 18) {
                        return false;
                    }

                    var form = $(this);

                    if (currentIndex < newIndex) {

                        $(".body:eq(" + newIndex + ") label.error", form).remove();
                        $(".body:eq(" + newIndex + ") .error", form).removeClass("error");
                    }


                    form.validate().settings.ignore = ":disabled,:hidden";


                    return form.valid();
                },
                onStepChanged: function (event, currentIndex, priorIndex) {

                    if (currentIndex === 2 && Number($("#age").val()) >= 18) {
                        $(this).steps("next");
                    }


                    if (currentIndex === 2 && priorIndex === 3) {
                        $(this).steps("previous");
                    }
                },
                onFinishing: function (event, currentIndex) {
                    var form = $(this);

                    form.validate().settings.ignore = ":disabled";

                    return form.valid();
                },
                onFinished: function (event, currentIndex) {
                    var form = $(this);

                    form.submit();
                }
            }).validate({
                errorPlacement: function (error, element) {
                    element.before(error);
                },
                rules: {
                    confirm: {
                        equalTo: "#spassword"
                    },
                    userPassword:{
                        remote: {
                            type: "get",
                            url: "${path}/info/detection",// {userId:userId,userPassword:pass},
                            data: {
                                userId:${sessionScope.user.userId},
                                userPassword: function() {
                                    return $("#spassword").val();
                                }
                            },
                            dataType: "html",
                            dataFilter: function(data, type) {
                                if (data == "true")
                                    return true;
                                else
                                    return false;
                            }
                        }
                    },
                    numder:{
                        isIdCardNo:true,
                        cardExist:true,
                        remote:{
                            type:"get",
                            url:"${path}/info/cradTrue",
                            data:{
                                name:function () {
                                   return $("#name").val();
                                },
                                numder:function () {
                                    return $("#card").val();
                                }
                            },
                            dataType: "html",
                            dataFilter: function(data, type) {
                                console.log(data);
                                if (data == "true")
                                    return true;
                                else
                                    return false;
                            }
                        }
                    }
                },
                messages:{
                    userPassword:{
                        remote:"密码不正确!请重新输入."
                    },
                    numder:{
                        remote:"您输入的证件号不存在或与所属姓名不符,请重新输入."
                    }
                }
            });

            //模块4  绑定手机
            $("#form4").steps({
                bodyTag: "fieldset",
                onStepChanging: function (event, currentIndex, newIndex) {
                    if (currentIndex > newIndex) {
                        return true;
                    }
                    if (newIndex === 3 && Number($("#age").val()) < 18) {
                        return false;
                    }

                    var form = $(this);

                    if (currentIndex < newIndex) {

                        $(".body:eq(" + newIndex + ") label.error", form).remove();
                        $(".body:eq(" + newIndex + ") .error", form).removeClass("error");
                    }


                    form.validate().settings.ignore = ":disabled,:hidden";


                    return form.valid();
                },
                onStepChanged: function (event, currentIndex, priorIndex) {

                    if (currentIndex === 2 && Number($("#age").val()) >= 18) {
                        $(this).steps("next");
                    }


                    if (currentIndex === 2 && priorIndex === 3) {
                        $(this).steps("previous");
                    }
                },
                onFinishing: function (event, currentIndex) {
                    var form = $(this);

                    form.validate().settings.ignore = ":disabled";

                    return form.valid();
                },
                onFinished: function (event, currentIndex) {
                    var form = $(this);

                    form.submit();
                }
            }).validate({
                errorPlacement: function (error, element) {
                    element.before(error);
                },
                rules: {
                    confirm: {
                        equalTo: "#ppassword"
                    },
                    userPassword:{
                        remote: {
                            type: "get",
                            url: "${path}/info/detection",// {userId:userId,userPassword:pass},
                            data: {
                                userId:${sessionScope.user.userId},
                                userPassword: function() {
                                    return $("#ppassword").val();
                                }
                            },
                            dataType: "html",
                            dataFilter: function(data, type) {
                                if (data == "true")
                                    return true;
                                else
                                    return false;
                            }
                        }
                    },
                    uPhone:{
                        isMobile: true,
                        remote:{
                            type:"get",
                            url:"${path}/info/isPhone",
                            data:{
                                uPhone:function () {
                                    return $("#phone").val();
                                }
                            },
                            dataType:"html",
                            dataFilter:function (data,type) {
                                if(data == "true")
                                    return true;
                                else
                                    return false;
                            }
                        }
                    },
                    validations:{
                        remote:{
                            type:"post",
                            url:"${path}/info/yzm",
                            data:{
                                yzm:function () {
                                    return $("#yzm").val();
                                }
                            },
                            dataType:"html",
                            dataFilter:function (data,type) {
                                if(data == "true")
                                    return true;
                                else
                                    return false;
                            }
                        }
                    }
                },
                messages:{
                    userPassword:{
                        remote:"密码不正确!请重新输入."
                    },
                    uPhone:{
                        remote:"手机号已经被绑定到其他账户,请重新输入"
                    },
                    validations:{
                        remote:"验证码有误,请确认后输入"
                    }
                }
            });

            // 互相跳转

            $("#safety1").click(function () {
                $("#safety1").addClass("info");
                $("#safety2").removeClass("info");
                $("#safety3").removeClass("info");
                $("#safety4").removeClass("info");
                $("#block1").show();
                $("#block2").hide();
                $("#block3").hide();
                $("#block4").hide();
            });

            $("#safety2").click(function () {
                $("#safety2").addClass("info");
                $("#safety1").removeClass("info");
                $("#safety3").removeClass("info");
                $("#safety4").removeClass("info");
                $("#block2").show();
                $("#block1").hide();
                $("#block3").hide();
                $("#block4").hide();
            });

            $("#safety3").click(function () {
                $("#safety3").addClass("info");
                $("#safety1").removeClass("info");
                $("#safety2").removeClass("info");
                $("#safety4").removeClass("info");
                $("#block3").show();
                $("#block2").hide();
                $("#block1").hide();
                $("#block4").hide();
            });

            $("#safety4").click(function () {
                $("#safety4").addClass("info");
                $("#safety1").removeClass("info");
                $("#safety2").removeClass("info");
                $("#safety3").removeClass("info");
                $("#block4").show();
                $("#block2").hide();
                $("#block1").hide();
                $("#block3").hide();
            });





        });

        function isHave() {
            alert("操作成功!!!");
        }

    </script>

</div>
</body>

</html>
